package com.cskaoyan.service.admin;

import com.cskaoyan.bean.admin.dashboard.GoodsExample;
import com.cskaoyan.bean.admin.dashboard.OrderExample;
import com.cskaoyan.bean.admin.dashboard.ProductExample;
import com.cskaoyan.bean.admin.dashboard.UserExample;
import com.cskaoyan.mapper.admin.dashboard.GoodsMapperByAdmin;
import com.cskaoyan.mapper.admin.dashboard.OrderMapperByAdmin;
import com.cskaoyan.mapper.admin.dashboard.ProductMapperByAdmin;
import com.cskaoyan.mapper.admin.dashboard.UserMapperByAdmin;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * 类<code>Doc</code>用于：TODO
 *
 * @author Acher
 * @version 1.0
 * @date 2021-10-21
 */
@Service
public class DashBoardServiceImpl implements DashBoardService{

    @Autowired
    GoodsMapperByAdmin goodsMapperByAdmin;
    @Autowired
    OrderMapperByAdmin orderMapperByAdmin;
    @Autowired
    ProductMapperByAdmin productMapperByAdmin;
    @Autowired
    UserMapperByAdmin userMapperByAdmin;

    @Override
    public Map<String, Integer> query() {
        Map<String, Integer> map = new HashMap<>();
        int goodsTotal = (int) goodsMapperByAdmin.countByExample(new GoodsExample());
        map.put("goodsTotal", goodsTotal);
        int orderTotal = (int) orderMapperByAdmin.countByExample(new OrderExample());
        map.put("orderTotal", orderTotal);
        int productTotal = (int) productMapperByAdmin.countByExample(new ProductExample());
        map.put("productTotal", productTotal);
        int userTotal = (int) userMapperByAdmin.countByExample(new UserExample());
        map.put("userTotal", userTotal);
        return map;
    }
}
